{include file="admin/common/mainHead"/}
<div class="admin-main fadeInUp animated">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>{$title}</legend>
    </fieldset>
    <form class="layui-form layui-form-pane">

        <div class="layui-form-item">
            <label class="layui-form-label">项目名称</label>
            <div class="layui-input-4">
                <input type="text" name="project_name" lay-verify="required" placeholder="{:lang('pleaseEnter')}项目名称" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux red">*</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">项目LOGO</label>
            <div class="layui-upload">
            	<div style="overflow:hidden;">
					<button class="layui-btn uploadimg" type="button" lay-data="{url: '/a/'}" style="float:left;">上传图片</button>
			    	<div class="layui-form-mid layui-word-aux">（尺寸：500*500px  格式：jpg/png）</div>
			    </div>
			    <div class="layui-upload-list">
			        <img class="layui-upload-img">
			        <p class="img-text"></p>
			    </div>
			</div>   
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">首页背景图</label>
            <div class="layui-upload">
            	<div style="overflow:hidden;">
			    	<button class="layui-btn uploadimg" type="button" lay-data="{url: '/b/', size:5}" style="float:left;">上传图片</button>
			    	<div class="layui-form-mid layui-word-aux">（尺寸：500*500px  格式：jpg/png）</div>
			    </div>
			    <div class="layui-upload-list">
			        <img class="layui-upload-img">
			        <p class="img-text"></p>
			    </div>
			</div>   
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">合同图</label>
            <div class="layui-upload">
            	<div style="overflow:hidden;">
					<button class="layui-btn uploadimg" type="button" lay-data="{url: '/c/', accept: 'file',size:10}" style="float:left;">上传图片</button>
			    	<div class="layui-form-mid layui-word-aux">（尺寸：500*500px  格式：jpg/png）</div>
			    </div>
			    <div class="layui-upload-list">
			        <img class="layui-upload-img" >
			        <p class="img-text"></p>
			    </div>
			</div>   
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">合同地址</label>
            <div class="layui-input-4">
                <input type="text" name="contract_addr" lay-verify="required" placeholder="{:lang('pleaseEnter')}合同地址" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux red">*</div>
        </div>

		<div class="layui-form-item">
            <label class="layui-form-label">微信选房协议</label>
            <div class="layui-input-6">
                <textarea id="textarea_box" style="display: none;"></textarea>
            </div>
            <div class="layui-form-mid layui-word-aux red">*</div>
        </div>

       	<div class="layui-form-item">
            <label class="layui-form-label">选房开始时间</label>
            <div class="layui-input-4">
	        	<input type="text" name="start_time" class="layui-input gettime" placeholder="yyyy-MM-dd HH:mm:ss">
	        </div>
            <div class="layui-form-mid layui-word-aux red">*</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">选房结束时间</label>
            <div class="layui-input-4">
	        	<input type="text" name="end_time" class="layui-input gettime" placeholder="yyyy-MM-dd HH:mm:ss">
	        </div>
            <div class="layui-form-mid layui-word-aux red">*</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">价格开放时间</label>
            <div class="layui-input-4">
	        	<input type="text" name="price_release_time" class="layui-input gettime" placeholder="yyyy-MM-dd HH:mm:ss">
	        </div>
            <div class="layui-form-mid layui-word-aux red">*</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">认筹开放时间</label>
            <div class="layui-input-4">
	        	<input type="text" name="subscription_time" class="layui-input gettime" placeholder="yyyy-MM-dd HH:mm:ss">
	        </div>
            <div class="layui-form-mid layui-word-aux red">*</div>
        </div>
       
        <div class="layui-form-item">
            <label class="layui-form-label">认购时长</label>
            <div class="layui-input-2">
                <input type="text" name="duration" lay-verify="required" placeholder="{:lang('pleaseEnter')}认购时长" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">分</div>
            <div class="layui-form-mid layui-word-aux red">*</div>
        </div>

       	<div class="layui-form-item">
            <label class="layui-form-label">收藏数量</label>
            <div class="layui-input-2">
                <input type="text" name="collect_number" lay-verify="required" placeholder="{:lang('pleaseEnter')}收藏数量" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">每个筹号对应可收藏的数量</div>
            <div class="layui-form-mid layui-word-aux red">*</div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
                <a href="{:url('index')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
            </div>
        </div>
    </form>
</div>
{include file="admin/common/mainFoot"/}
<script>
layui.use(['layedit','laydate','upload'], function(){
	var $ = layui.jquery
	,layedit = layui.layedit
 	,laydate = layui.laydate
  	,upload = layui.upload;


  	//富文本编辑器
 	 layedit.build('textarea_box'); //建立编辑器

	//时间选择器 同时绑定多个
    lay('.gettime').each(function(){
        laydate.render({
            elem: this,
            trigger: 'click',
            type: 'datetime'
        });
    });

  // //普通图片上传
  // var uploadInst = upload.render({
  //   elem: '#upload1'
  //   ,url: '/upload/'
  //   ,before: function(obj){
  //     //预读本地文件示例，不支持ie8
  //     obj.preview(function(index, file, result){
  //       $('#imgBox').attr('src', result); //图片链接（base64）
  //     });
  //   }
  //   ,done: function(res){
  //     //如果上传失败
  //     if(res.code > 0){
  //       return layer.msg('上传失败');
  //     }
  //     //上传成功
  //   }
  //   ,error: function(){
  //     //演示失败状态，并实现重传
  //     var demoText = $('#Text1');
  //     demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
  //     demoText.find('.demo-reload').on('click', function(){
  //       uploadInst.upload();
  //     });
  //   }
  // });

    //同时绑定多个元素，并将属性设定在元素上
	var uploadInst = upload.render({
	    elem: '.uploadimg'
	    ,url: '{:url("admin.upload/upload")}' //上传接口
	    ,data: {} //可选项。额外的参数，如：{id: 123, abc: 'xxx'}
	    ,before: function(obj){
	        //预读本地文件示例，不支持ie8
	    	var item = this.item;
		    obj.preview(function(index, file, result){
		    	var img_box = $(item).parent().next().find('.layui-upload-img');
		    	img_box.show();
		    	img_box.attr('src', result); //图片链接（base64）
		    });
	        //layer.tips('接口地址：'+ this.url, this.item, {tips: 1});
	    }
	    ,done: function(res, index, upload){
	    	//上传完毕回调
	       var item = this.item;
	        console.log(item); //获取当前触发上传的元素，layui 2.1.0 新增
	    }
	    ,accept: 'file' //允许上传的文件类型
	    ,error: function(){
	        //请求异常回调
	        //演示失败状态，并实现重传
	        var item = this.item;
		    var imgText = $(item).parents('.layui-upload').find('.img-text');
		    imgText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini btn-reload">重试</a>');
		    imgText.find('.btn-reload').on('click', function(){
		        uploadInst.upload();
		    });
	    }
	})
});
</script>

